import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading

/* layout */
import Layout from '../views/layout/Layout'

Vue.use(Router)

/**
* icon : the icon show in the sidebar
* hidden : if `hidden:true` will not show in the sidebar
* redirect : if `redirect:noredirect` will not redirct in the levelbar
* noDropdown : if `noDropdown:true` will not has submenu in the sidebar
* meta : `{ role: ['admin'] }`  will control the page role
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/404', component: _import('404'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    icon: 'chart',
    noDropdown: true,
    children: [{ path: 'dashboard', name: '总览',component: _import('dashboard/index') }]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/all',
    icon: 'order',
    noDropdown: true,
    children: [
      { path: 'index', name: '订单管理', icon: 'zujian', component: _import('order/all') },
      { path: 'detail', name: '订单详情', icon: 'zujian', component: _import('order/detail'), hidden: true }
    ]
  },
  {
    path: '/goods',
    component: Layout,
    redirect: 'noredirect',
    name: '商品管理',
    icon: 'goods',
    children: [
      { path: 'index', name: '分类管理', icon: 'zujian', component: _import('goods/classify') },
      { path: 'all', name: '全部商品', icon: 'zujian', component: _import('goods/all') },
      { path: 'new', name: '添加商品', icon: 'zujian', component: _import('goods/new') }
    ]
  },
  {
    path: '/grade',
    component: Layout,
    redirect: 'noredirect',
    icon: 'grade',
    noDropdown: true,
    children: [
      { path: 'index', name: '评价管理', icon: 'zujian', component: _import('grade/index') },
      { path: 'grade', name: '评价详情', icon: 'zujian', component: _import('grade/grade') }
    ]
  },
  {
    path: '/strategy',
    component: Layout,
    redirect: 'noredirect',
    name: '攻略管理',
    icon: 'gonglue',
    children: [
      { path: 'index', name: '已发布', icon: 'zujian', component: _import('strategy/all') },
      { path: 'new', name: '新攻略', icon: 'zujian', component: _import('strategy/new') }
    ]
  },
  {
    path: '/activity',
    component: Layout,
    redirect: 'noredirect',
    name: '活动管理',
    icon: 'huodong',
    children: [
      { path: 'index', name: '已发布', icon: 'zujian', component: _import('activity/all') },
      { path: 'new', name: '新活动', icon: 'zujian', component: _import('activity/new') }
    ]
  },
  {
    path: '/sport',
    component: Layout,
    redirect: 'noredirect',
    name: '一起去玩',
    icon: 'sport',
    children: [
      { path: 'index', name: '已发布', icon: 'zujian', component: _import('sport/all') },
      { path: 'new', name: '新发起', icon: 'zujian', component: _import('sport/new') }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: 'noredirect',
    icon: 'user',
    noDropdown: true,
    children: [
      { path: 'index', name: '会员中心', icon: 'zujian', component: _import('user/index') },
      { path: 'edit', name: '编辑商家信息', icon: 'zujian', component: _import('user/edit') }
    ]
  },
  {
    path: '/chat',
    component: Layout,
    redirect: 'noredirect',
    icon: 'chat',
    noDropdown: true,
    children: [
      { path: 'index', name: '客服消息', icon: 'zujian', component: _import('chat/index') }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

